#include <iostream>
#include <cstdio>

using namespace std; 

int win[5][5] = {
	{0,  -1,  1,  1, -1}, 
	{1,   0, -1,  1, -1}, 
	{-1,  1,  0, -1,  1}, 
	{-1, -1,  1,  0,  1}, 
	{1,   1, -1, -1,  0}, 
}; 

#define N 201

int n, na, nb; 
int la[N], lb[N]; 

int main()
{
	int i, pa, pb, a, b; 
	int sa=0, sb=0; 
	
	//freopen("p1328_1.in", "r", stdin); 
	
	cin>>n>>na>>nb; 
	
	for (i=0; i<na; i++) {
		cin>>la[i]; 
	}

	for (i=0; i<nb; i++) {
		cin>>lb[i]; 
	}

	for (i=0; i<n; i++) {
		pa = i%na; 
		pb = i%nb; 
		a = la[pa]; 
		b = lb[pb]; 
		if (win[a][b]==1) {
			sa += 1; 
		} else if (win[a][b]==-1) {
			sb += 1; 
		} else {
			// do nothing 
		}
	}
	cout << sa << " " << sb; 
	return 0; 
}


